<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>菜品类别编辑</title>

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <i th:replace="~{common :: baseUrl}"></i>
</head>
<body>
<form class="layui-form" action=""  lay-filter="example">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">桌位编号</label>
            <div class="layui-input-inline">
                <input type="text"  id="id"  readonly name="id" th:value="${shopTable.id}" lay-verify="required"    class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">桌位名称</label>
            <div class="layui-input-inline">
                <input type="text" name="tableName" id="tableName" th:value="${shopTable.tableName}" lay-verify="required"  class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">桌位状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="客满" th:checked="${shopTable.status == 1}">
            <input type="radio" name="status" value="0" title="无客" th:checked="${shopTable.status == 0}">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">容纳人数</label>
            <div class="layui-input-inline">
                <input type="text" name="num" id="num" th:value="${shopTable.num}" lay-verify="number"  class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">所在楼层</label>
            <div class="layui-input-inline">
                <input type="text" name="floorNum" id="floorNum" th:value="${shopTable.floorNum}"lay-verify="number"  class="layui-input">
            </div>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">所在店铺</label>
        <div class="layui-input-inline">
            <select name="merchantsId" id="merchantsId" lay-verify="required"  disabled >
                <option th:each="f : ${merchantsInformationList}"  th:value="${f.id}" th:text="${f.name}" th:selected="${shopTable.merchantsId eq f.id}"></option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>



</body>
<script th:src="@{/layui/layui.js}"></script>
<script th:inline="none">
    //JavaScript代码区域
    layui.use(['element','form','upload','layer','laydate'], function() {
        var element = layui.element;
        var form = layui.form;
        var upload = layui.upload;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var $ = layui.$;

        //提交
        form.on('submit(sub)', function(data){

            //发送ajax请求  编辑APP信息
            $.ajax({
                url:baseUrl+"shop/table/edit",
                data:data.field,
                type:"post",
                dataType:"json",
                success:function (result) {
                    if (result.code==0){
                        layer.open({
                            title: '编辑桌位信息'
                            ,content: '编辑成功！'
                            ,end:function () {
                                //当你在iframe页面关闭自身时
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            }
                        });
                    }else {
                        layer.open({
                            title: '编辑菜品分类信息'
                            ,content: result.msg
                        });
                    }
                },
                error:function () {
                    layer.msg("服务器原地爆炸,请联系管理员!!!");
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。

        });





    });

</script>
</html>